//package com.letu.mq.config;
//
//
//import com.letu.mq.listener.OrderRocketMQLisenter;
//import com.letu.mq.model.RocketMqEvent;
//import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.client.exception.MQClientException;
//import org.apache.rocketmq.client.producer.DefaultMQProducer;
//import org.apache.rocketmq.client.producer.LocalTransactionState;
//import org.apache.rocketmq.client.producer.TransactionMQProducer;
//import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
//import org.apache.rocketmq.common.message.MessageExt;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.ApplicationEventPublisher;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.List;
//import java.util.Set;
//import java.util.concurrent.ArrayBlockingQueue;
//import java.util.concurrent.ThreadPoolExecutor;
//import java.util.concurrent.TimeUnit;
//
//
//@Configuration
//@EnableConfigurationProperties(RocketMqProperties.class)
//public class RocketMqConfiguration {
//
//    @Autowired
//    private RocketMqProperties rmqProperties;
//
//    /**
//     * 发送普通消息
//     */
//    @Bean(name = "defaultProduce")
//    public DefaultMQProducer defaultMQProducer() throws MQClientException {
//        DefaultMQProducer producer = new DefaultMQProducer(rmqProperties.getDefaultProducer());
//        producer.setNamesrvAddr(rmqProperties.getNamesrvAddr());
//        producer.setInstanceName(rmqProperties.getInstanceName());
//        producer.setVipChannelEnabled(false);
//        producer.start();
//        return producer;
//    }
//
////    /**
////     * 发送订单事务消息
////     */
////    @Bean(name = "trans")
////    public TransactionMQProducer transactionMQProducer() throws MQClientException {
////        TransactionMQProducer producer = new TransactionMQProducer(rmqProperties.getOrderTransactionProducer());
////        producer.setNamesrvAddr(rmqProperties.getNamesrvAddr());
////        producer.setInstanceName(rmqProperties.getInstanceName());
////
////        //自定义线程池,执行事务操作
////        ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 50, 10L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(20), (Runnable r) -> new Thread("Order Transaction Massage Thread"));
////        producer.setExecutorService(executor);
////
////
////        producer.setTransactionListener(new OrderRocketMQLisenter());
//////		producer.setTransactionCheckListener((MessageExt msg) ->{
//////			System.out.println("事务回查机制！");
//////			return  LocalTransactionState.COMMIT_MESSAGE;
//////		});
//////		// 事务回查最小并发数
//////		producer.setCheckThreadPoolMinSize(2);
//////		// 事务回查最大并发数
//////		producer.setCheckThreadPoolMaxSize(5);
//////		// 队列数
//////		producer.setCheckRequestHoldMax(2000);
////        producer.start();
////        return producer;
////    }
//
//
//}
